#ifndef CONVERSATIONMODEL_H
#define CONVERSATIONMODEL_H

#include "converse/converseabstractmessage.h"

#include <QObject>
#include <QAbstractListModel>
#include <QtQml/qqml.h>
#include <QList>


class ConversationModel : public QAbstractListModel
{
    Q_OBJECT
public:
    enum ConversationRoles {
        IdRole = Qt::UserRole + 1,
        SendingIdRole,
        SenderIdRole,
        ReceiverIdRole,
        CreatedTimeRole,
        ReceiveTimeRole,
        TypeRole,
        MessageRole,
        ExtraRole,
        AvatarRole,
        DeliveredMessageRole,
        IsCombinedMessageRole,
        DateTimeCombinationRole
    };
    ConversationModel(QObject *parent = 0);

    void addConversation(Converse::AbstractMessage* conversation);

    void editConversation(Converse::AbstractMessage* conversation);

    void insertConversation(const int pos, Converse::AbstractMessage* conversation);

    int rowCount(const QModelIndex & parent = QModelIndex()) const;

    QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;

    void clear();

public slots:

    void setListConversation(const QList < Converse::AbstractMessage *> _listConversation);

protected:
    QHash<int, QByteArray> roleNames() const;

private:
    QList < Converse::AbstractMessage *> m_listConversation;
    QList < bool > m_listIsCombinedMessage;

};

QML_DECLARE_TYPE(ConversationModel)

#endif // CONVERSATIONMODEL_H
